import pandas as pd

def signal(*args):  # 只接受两个参数：df 和 param
    df = args[0]
    n = args[1]
    factor_name = args[2]
    m = 2*n
    
    # 计算短期的最大最小值
    short_max = df['volume'].rolling(int(n), min_periods=1).max()
    short_min = df['volume'].rolling(int(n), min_periods=1).min()
    short_range = short_max - short_min

    # 计算长期的最大最小值
    long_max = df['volume'].rolling(int(m), min_periods=1).max()
    long_min = df['volume'].rolling(int(m), min_periods=1).min()
    long_range = long_max - long_min
    
    df[factor_name] = short_range / long_range

    return df